//
//  CourseWork.m
//  Gradekeeper0.2
//
//  Created by Qian Tim on 09-11-17.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "CourseWork.h"

@interface CourseWork (hidden)

-(void) setPercentage;

@end

@implementation CourseWork (hidden)

-(void) setPercentage {
	percentage=(mark/maxMark*100);
}

@end


@implementation CourseWork

-(CourseWork*) initWithName: (NSString*) newName Type: (NSString*) newType maxMark: (float) newMaxMark startDate: (Date*) newStartDate dueDate: (Date*) newDueDate {
	self = [super init];
	
    if ( self ) {
       	self.name = name;
		self.type = type;
		self.startDate = startDate;
		self.dueDate = dueDate;
		self.mark = 0;
		self.maxMark = maxMark;
		[self setPercentage];
    }
	
    return self;
}

-(void) setMark: (float) newMark {
	mark = newMark;
	[self setPercentage];
}

-(void) setName: (NSString*) newName {
	[name release];
	name = newName;
}

-(void) setMaxMark: (float) newMaxMark {
	maxMark = newMaxMark;
}

-(void) setType: (NSString*) newType {
	[type release];
	type = newType;
}

-(void) setStartDate: (Date*) newStartDate {
	[startDate release];
	startDate = newStartDate;
}

-(void) setDueDate: (Date*) newDueDate {
	[dueDate release];
	dueDate = newDueDate;
}

-(float) getMark {
	return mark;
}

-(float) getMaxMark {
	return maxMark;
}

-(float) getPercentage {
	return percentage;
}

-(NSString*) getName {
	return name;
}

-(NSString*) getType {
	return type;
}

-(Date*) getStartDate {
	return startDate;
}

-(Date*) getDueDate {
	return dueDate;
}

@end
